﻿using System;
using System.Text;

namespace Alex.Library.Web.Ajax
{
    /// <summary>
    /// 文本序列化工具类
    /// </summary>
    class TextSerializeHelper : SerializeHelper
    {
        /// <summary>
        /// 是否允许序列化null值
        /// </summary>
        public override bool IncludeNull { get; set; }

        /// <summary>
        /// 将对象序列化为字符串
        /// </summary>        
        /// <param name="obj">对象</param>
        /// <param name="encoding">字符编码</param>
        /// <returns></returns>
        public override string Serialize<T>(T obj, Encoding encoding)
        {
            return obj.ToString();
        }

        /// <summary>
        /// 将对象序列化为字符串
        /// </summary>        
        /// <param name="obj">对象</param>
        /// <param name="encoding">字符编码</param>
        /// <returns></returns>
        public override string Serialize(object obj, Encoding encoding)
        {
            return obj.ToString();
        }

        /// <summary>
        /// 将字符串中反序列化为对象
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="serializeString">JSON字符串</param>
        /// <param name="encoding">字符编码</param>
        /// <returns></returns>
        public override T Deserialize<T>(string serializeString, Encoding encoding)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// 将字符串中反序列化为对象
        /// </summary>
        /// <param name="serializeString">JSON字符串</param>
        /// <param name="type">反序列化对象的类型</param>
        /// <param name="encoding">字符编码</param>
        /// <returns></returns>
        public override object Deserialize(string serializeString, Type type, Encoding encoding)
        {
            throw new NotImplementedException();
        }
    }
}
